// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';

// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed

let statusBarItem : vscode.StatusBarItem

function updateProxyState(){
	const proxySetting = vscode.workspace.getConfiguration().get<string>('http.proxy')
	statusBarItem.text = 'Proxy: ' + (proxySetting || 'None');
}

export function activate({subscriptions}: vscode.ExtensionContext) {

	statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100)
	updateProxyState()
	statusBarItem.show()

	subscriptions.push(statusBarItem)
	subscriptions.push(
		vscode.workspace.onDidChangeConfiguration(e => {
			if(e.affectsConfiguration('http.proxy')){
				updateProxyState()
			}
		})
	)
	
}

// This method is called when your extension is deactivated
export function deactivate() {}
